package com.android.example.ActionBarExample2;

import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.app.ActionBar.TabListener;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class Main extends Activity implements OnCheckedChangeListener, TabListener {
    private RadioButton navStandard;
    private RadioButton navTabs;
    private RadioButton navList;
    
    private CheckBox showAsUp;
    private CheckBox useLogo;
    private CheckBox showTitle;
    
	String[] items = new String[]{
			"First",
			"Second",
			"Third"};
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        navStandard = (RadioButton)findViewById(R.id.nav_std);
        navTabs = (RadioButton)findViewById(R.id.nav_tab);
        navList = (RadioButton)findViewById(R.id.nav_list);
        
        showAsUp = (CheckBox)findViewById(R.id.show_as_up);
        useLogo = (CheckBox)findViewById(R.id.use_logo);
        showTitle = (CheckBox)findViewById(R.id.show_title);
        
        navStandard.setOnCheckedChangeListener(this);
        navTabs.setOnCheckedChangeListener(this);
        navList.setOnCheckedChangeListener(this);
        
        showAsUp.setOnCheckedChangeListener(this);
        useLogo.setOnCheckedChangeListener(this);
        showTitle.setOnCheckedChangeListener(this);
        
        ActionBar mActionBar = getActionBar();
        mActionBar.addTab(mActionBar.newTab().setText("First").setTabListener(this));
        mActionBar.addTab(mActionBar.newTab().setText("Second").setTabListener(this));
        mActionBar.addTab(mActionBar.newTab().setText("Third").setTabListener(this));
        
//    	ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items);

    }
    
	public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
		// TODO Auto-generated method stub
		ActionBar mActionBar = getActionBar();
		
		switch(buttonView.getId()){
		case R.id.nav_std:
			if(isChecked)
				mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
			break;
			
		case R.id.nav_tab:
			if(isChecked)
				mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
			break;
			
		case R.id.nav_list:
			if(isChecked)
				mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
			
			    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, items);
				mActionBar.setListNavigationCallbacks(adapter, new DropDownListenser(this));
			break;
			
		case R.id.show_as_up:
			mActionBar.setDisplayHomeAsUpEnabled(isChecked);
			
		case R.id.use_logo:
			mActionBar.setDisplayUseLogoEnabled(isChecked);
			break;
			
		case R.id.show_title:
			mActionBar.setDisplayShowTitleEnabled(isChecked);
			break;
		}
		
	}

	public void onTabReselected(Tab tab, FragmentTransaction ft) {
		// TODO Auto-generated method stub
		
	}

	public void onTabSelected(Tab tab, FragmentTransaction ft) {
		// TODO Auto-generated method stub
		
	}

	public void onTabUnselected(Tab tab, FragmentTransaction ft) {
		// TODO Auto-generated method stub
		
	}
}